package com.cbgolf.oa.widget;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by lq on 2017/11/14.
 */

public class RecyclerItemDecoration extends RecyclerView.ItemDecoration {
    private int left;
    private int right;
    private int top;
    private int bottom;

    public RecyclerItemDecoration(int top, int bottom, int left, int right) {
        this.top = top;
        this.left = left;
        this.bottom = bottom;
        this.right = right;
    }

    public RecyclerItemDecoration(int left, int right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        if (parent.getChildPosition(view) != 0) {
            outRect.top = top;
            outRect.bottom = bottom;
            outRect.right = right;
            outRect.left = left;
        }
    }
}
